package com.magold.touch;

import org.andengine.entity.scene.Scene;
import org.andengine.input.touch.TouchEvent;

public abstract class BaseDirectable implements IDirectable {
	private boolean skip;
	private boolean mEnabled;
	
	public BaseDirectable() {
		mEnabled = true;
	}
	
	@Override
	public final boolean onDetecting(Scene pScene, TouchEvent pEvent) {
		if (skip || !mEnabled) return false;
		
		return onManagedDetecting(pScene, pEvent);
	}
	
	public abstract boolean onManagedDetecting(Scene pScene, TouchEvent pEvent);
	
	@Override
	public void setEnabled(boolean pEnabled) {
		mEnabled = pEnabled;
	}
	
	@Override
	public void skipCurrEvent() {
		skip = true;
	}
	
	@Override
	public void prepareNextEvent() {
		skip = false;
	}
	
	@Override
	public final void reset() {
		prepareNextEvent();
		resetTemplate();
	}
	
	protected abstract void resetTemplate();
}
